package com.lizhuo.yygh.cmn.controller;

import com.atguigu.yygh.model.cmn.Dict;
import com.lizhuo.yygh.cmn.service.DictService;
import com.lizhuo.yygh.common.result.Result;
import com.sun.codemodel.internal.JVar;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.hssf.record.DVALRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Api(tags = "数据字典")
@RestController
@RequestMapping("/admin/cmn/dict")
public class DictController {

    @Autowired
    private DictService dictService;

    /**
     * 导出数据字典
     * */
    @ApiOperation(value = "导出数据字典")
    @GetMapping("/exportData")
    public void exportData(HttpServletResponse response) {
        dictService.exportData(response);
    }

    /**
     * 根据数据id查询子数据列表
     * */
    @ApiOperation(value = "根据数据id查询子数据列表")
    @GetMapping("/findChildDate/{id}")
    public Result findChildData(@PathVariable Long id) {
        List<Dict> list = dictService.findChildData(id);
        return Result.ok(list);
    }

}
